package com.xopencode.spring;

import com.xopencode.spring.config.SpringConfig;
import org.springframework.context.annotation.AnnotationConfigApplicationContext;
import org.springframework.core.env.ConfigurableEnvironment;

/**
 * @Auther: Mcb
 * @Date: 2022/3/1 22:52
 * @Description: 获取运行时环境 1.操作系统 2.jvm环境变量 3.properties文件
 */
public class EnvironmentLoad {

    public static void main(String[] args) {
        AnnotationConfigApplicationContext applicationContext = new AnnotationConfigApplicationContext(SpringConfig.class);

        ConfigurableEnvironment environment = applicationContext.getEnvironment();
        System.out.println(environment.getSystemProperties()); //系统环境变量
        System.out.println("\n");
        System.out.println(environment.getSystemEnvironment());//jvm环境变量
        System.out.println("\n");
        System.out.println(environment.getSystemProperties());
        System.out.println(environment.getProperty("xopencode"));
    }
}
